package com.color.admin.system.entity.query;


import com.color.admin.common.core.annotation.Query;
import com.color.admin.common.core.utils.web.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * @author HaiQiu
 * @date 2021/12/24
 */
public class UserQueryCriteria implements Serializable {

    @Query
    private String id;

    @JsonIgnore
    @Query(propName = "id",type = Query.Type.IN,joinName = "dept")
    private Set<String> deptIds = new HashSet<>();

    @Schema(description = "岗位ID集合查询")
    @Query(propName = "id",type = Query.Type.IN,joinName = "posts")
    private Set<String> postIds = new HashSet<>();

    @Schema(description = "角色ID集合查询")
    @Query(propName = "id",type = Query.Type.IN,joinName = "roles")
    private Set<String> roleIds = new HashSet<>();

    @Schema(description = "多字段查询，支持字段：email,username,nickname,realName")
    @Query(blurry = "email,username,nickname,realName")
    private String blurry;

    @Schema(description = "是否激活")
    @Query
    private Boolean active;

    @Schema(example = "xx",description = "模糊查询时的部门ID")
    private String deptId;

    @Schema(example = "true",description = "是否查询子部门，默认true")
    private Boolean findIsDeptChildren = true;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Set<String> getDeptIds() {
        return deptIds;
    }

    public void setDeptIds(Set<String> deptIds) {
        if (!CollectionUtils.isEmpty(deptIds)){
            deptIds.forEach(s -> {
                if (StringUtils.isBlank(s)){
                    deptIds.clear();
                }
            });
        }
        this.deptIds = deptIds;
    }

    public String getBlurry() {
        return blurry;
    }

    public void setBlurry(String blurry) {
        this.blurry = blurry;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public Boolean getFindIsDeptChildren() {
        return findIsDeptChildren;
    }

    public void setFindIsDeptChildren(Boolean findIsDeptChildren) {
        this.findIsDeptChildren = findIsDeptChildren;
    }

    public Set<String> getPostIds() {
        return postIds;
    }

    public void setPostIds(Set<String> postIds) {
        this.postIds = postIds;
    }

    public Set<String> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(Set<String> roleIds) {
        this.roleIds = roleIds;
    }
}
